home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
292_02
/
ast09.asm
< prev
next >
Wrap
Assembly Source File
|
1990-07-16
|
51KB
|
1,724 lines
.title assist09 - mc6809 monitor
.module assist09
.radix d
;* Modification date: November 23, 1988
;********************************************************
;* miscelaneous equates
;********************************************************
dftchp = 0 ; default character pad count
dftnlp = 0 ; default new line pad count
prompt = '> ; prompt character
numbkp = 8 ; number of breakpoints
eot = 0x04 ; end of transmission
bell = 0x07 ; bell character
lf = 0x0a ; line feed
cr = 0x0d ; carriage return
can = 0x18 ; cancel (ctl-x)
.page
.sbttl SWI Functions
;********************************************************
;* assist09 monitor swi functions
;*
;* the following equates define functions provided
;* by the assist09 monitor via the swi instruction.
;********************************************************
inchnp = 0 ; input char in a reg - no parity
outch = 1 ; output char from a reg
pdata1 = 2 ; output string
pdata = 3 ; output cr/lf then string
out2hs = 4 ; output two hex and space
out4hs = 5 ; output four hex and space
pcrlf = 6 ; output cr/lf
space = 7 ; output a space
monitr = 8 ; enter assist09 monitor
vctrsw = 9 ; vector examine/switch
brkpt = 10 ; user program breakpoint
pause = 11 ; task pause function
numfun = 11 ; number of available functions
;* sub-codes for accessing the vector table.
;* they are equivalent to offsets in the table.
;* relative positioning must be maintained.
.avtbl = 0 ; address of vector table
.cmdl1 = 2 ; first command list
.rsvd = 4 ; reserved hardware vector
.swi3 = 6 ; swi3 routine
.swi2 = 8 ; swi2 routine
.firq = 10 ; firq routine
.irq = 12 ; irq routine
.swi = 14 ; swi routine
.nmi = 16 ; nmi routine
.reset = 18 ; reset routine
.cion = 20 ; console on
.cidta = 22 ; console input data
.cioff = 24 ; console input off
.coon = 26 ; console output on
.codta = 28 ; console output data
.cooff = 30 ; console output off
.hsdta = 32 ; high speed printdata
.bson = 34 ; punch/load on
.bsdta = 36 ; punch/load data
.bsoff = 38 ; punch/load off
.pause = 40 ; task pause routine
.expan = 42 ; expression analyzer
.cmdl2 = 44 ; second command list
.pad = 46 ; character pad and new line pad
.echo = 48 ; echo/load and null bkpt flag
numvtr = 48/2+1 ; number of vectors
hivtr = 48 ; highest vector offset
.page
.sbttl Work Area
;********************************************************
;* work area
;*
;* The direct page register during most routine
;* operations will point to this work area. the Stack
;* initially starts under the reserved work areas as
;* defined herein.
;********************************************************
.area WORKPG (ABS,OVR)
.setdp 0
workpg: ; beginning of work aera
.blkb 0d256-(endpg-astack) ; stack space
astack: ; top of assist09 stack
tstack: .blkb 0d21 ; temporary stack hold
delim: .blkb 1 ; expression delimiter/work byte
misflg: .blkb 1 ; load cmd/thru breakpoint flag
swicnt: .blkb 1 ; trace "swi" nest level count
pcnter: .blkb 2 ; last program counter
pstack: .blkb 2 ; command recovery stack
rstack: .blkb 2 ; reset stack pointer
anumber:.blkb 2 ; binary build area
basepg: .blkb 1 ; base page value
addr: .blkb 2 ; address pointer value
window: .blkb 2 ; window
bkptop: .blkb 0x10 ; breakpoint opcode table
bkptbl: .blkb 0x10 ; breakpoint table
vectab: .blkb 0x32 ; vector table
bkptct: .blkb 1 ; breakpoint count
swibfl: .blkb 1 ; bypass swi as breakpoint flag
pauser: .blkb 4 ; pause routine
endpg:
.page
.sbttl Assist09 Code
.area ASSIST09 (ABS,OVR)
;********************************************************
;* bldvtr - build assist09 vector table
;*
;* hardware reset calls this subroutine to build the
;* assist09 vector table.
;*
;* input: s->valid stack ram
;* output: u->vector table address
;* dpr->assist09 work area page
;* the vector table and defaults are initialized
;*
;* all registers volatile
;********************************************************
bldvtr: leax vectab,pcr ; address vector table
tfr x,d ; obtain base page address
tfr a,dp ; setup dpr
sta *basepg ; store for quick reference
leau ,x ; return table to caller
stu ,x++ ; and init vector table address
ldb #numvtr-3 ; number relocatable vectors
pshs b ; store index on stack
leay initvt,pcr ; load from addr
1$: tfr y,d ; prepare address resolve
addd ,y++ ; to absolute address
std ,x++ ; into vector table
dec ,s ; count down
bne 1$ ; branch if more to insert
ldb #intve-intvs ; static value init length
2$: lda ,y+ ; load next byte
sta ,x+ ; store into position
decb ; count down
bne 2$ ; loop until done
puls pc,b ; return to initializer
;********************************************************
;* reset entry point
;*
;* hardware reset enters here if assist09 is enabled
;* to receive the mc6809 hardware vectors. we call
;* the bldvtr subroutine to initialize the vector
;* table, stack, and then fireup the monitor via swi
;* call.
;********************************************************
reset: leas astack,pcr ; setup initial stack
bsr bldvtr ; build vector table
1$: clra ; issue startup message
tfr a,dp ; default to page zero
swi ; perform monitor fireup
.byte monitr ; to enter command processing
bra 1$ ; reenter monitor if 'continue'
.page
.sbttl Vector Table
;********************************************************
;* initvt - initialize vector table
;*
;* this table is relocated to ram and represents the
;* initial state of the vector table. all addresses
;* are converted to absolute form. this table starts
;* with the second entry, ends with static constant
;* initialization data which carries beyond the table.
;********************************************************
initvt: .word cmdtb1-. ; default first command table
.word rsrvdr-. ; default undefined hardware vector
.word swi3r-. ; default swi3
.word swi2r-. ; default swi2
.word firqr-. ; default firq
.word irqr-. ; default irq routine
.word swir-. ; default swi routine
.word nmir-. ; default nmi routine
.word reset-. ; restart vector
.word cion-. ; default cion
.word cidta-. ; default cidta
.word cioff-. ; default cioff
.word coon-. ; default coon
.word codta-. ; default codta
.word cooff-. ; default cooff
.word hsdta-. ; default hsdta
.word bson-. ; default bson
.word bsdta-. ; default bsdta
.word bsoff-. ; default bsoff
.word cpause-. ; default pause routine
.word exp1-. ; default expression analyzer
.word cmdtb2-. ; default second command table
;* constants
;*
intvs: .byte dftchp,dftnlp ; default null padds
.word 0 ; default echo
.byte 0 ; initial breakpoint count
.byte 0 ; swi breakpoint level
rts ; default pause routine
intve = .
.page
.sbttl SWI Handler
;********************************************************
;* assist09 swi handler
;*
;* the swi handler provides all interfacing necessary
;* for a user program. a function byte is assumed to
;* follow the swi instruction. it is bound checked
;* and the proper routine is given control. this
;* invocation may also be a breakpoint interrupt.
;* if so, the breakpoint handler is entered.
;*
;* input: machine state defined for swi
;* output: varies according to function called. pc on
;*
;* callers stack incremented by one if valid call.
;* volatile registers: see functions called
;*
;* state: runs disabled unless function clears i flag.
;********************************************************
;* swi function vector table
swivtb: .word zinch-swivtb ; inchnp
.word zotch1-swivtb ; outch
.word zpdta1-swivtb ; pdata1
.word zpdata-swivtb ; pdata
.word zot2hs-swivtb ; out2hs
.word zot4hs-swivtb ; out4hs
.word zpcrlf-swivtb ; pcrlf
.word zspace-swivtb ; space
.word zmontr-swivtb ; monitr
.word zvswth-swivtb ; vctrsw
.word zbkpnt-swivtb ; bre